package com.xiaomaoaixue.wecom.domain.dto;

import cn.hutool.core.collection.CollectionUtil;
import com.xiaomaoaixue.common.core.utils.StringUtils;
import com.xiaomaoaixue.system.api.domain.SysDept;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 企业部门
 * @author: HaoN
 * @create: 2020-08-27 15:54
 **/
@Data
public class WeDepartMentDto extends WeResultDto {



    private List<DeartMentDto> department=new ArrayList<>();

    public WeDepartMentDto(){

    }


   /* public WeDepartMentDto(WeDepartment weDepartment){

        DeartMentDto deartMentDto=new WeDepartMentDto().new DeartMentDto();
        BeanUtils.copyPropertiesignoreOther(weDepartment,deartMentDto);
        department.add(deartMentDto);
    }
*/

    public List<SysDept> findWeDepartments(){
        List<SysDept> weDepartments=new ArrayList<>();
        if(CollectionUtil.isNotEmpty(this.department)){
            this.department.stream().forEach(k->{
                SysDept dept=new SysDept();
                dept.setDeptId(k.getId());
                dept.setDeptName(k.getName());
                dept.setParentId(k.getParentid());
                dept.setOrderNum(k.order.toString());
                if(k.getDepartment_leader().size()>0) {
                    dept.setLeader(k.getDepartment_leader().get(0));
                }
                weDepartments.add(dept);
            });

        }
        return weDepartments;
    }



    @Data
    public class DeartMentDto{

        private Long id;

        private String name;

        private Long parentid;

        private List<String> department_leader;

        private Long order;
    }



}
